// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_g;

import android.util.Log;
import com.nnee.p_i.cls_c;
import java.io.*;
import java.util.Calendar;
import java.util.Vector;

// Referenced classes of package com.nnee.g:
//            a

public class cls_b
{

    public cls_b()
    {
    }

    public static String a()
    {
        if(h != null)
        {
            b("mAppPath lockObj:", (new StringBuilder()).append("").append(v.hashCode()).toString());
            b("mAppPath hashCode:", (new StringBuilder()).append("").append(h.hashCode()).toString());
        }
        return h;
    }

    private static void a(File file, File file1, File file2, boolean flag)
    {
    	int j1=0;
    	int i1=0;
        long l1 = 0L;
        if(file2.exists())
            file2.delete();
        FileOutputStream fileoutputstream=null;
		try {
			fileoutputstream = new FileOutputStream(file2);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        byte abyte0[] = new byte[10240];
        if(file.exists())
        {
            long l3 = file.length();
            FileInputStream fileinputstream1=null;
			try {
				fileinputstream1 = new FileInputStream(file);
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            
            for(long l4 = l1; l4 < l3; l4 += j1)
            {
                try {
					j1 = fileinputstream1.read(abyte0);
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
                try {
					fileoutputstream.write(abyte0, 0, j1);
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
            }

            try {
				fileinputstream1.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        }
        if(file1.exists())
        {
            long l2 = file1.length();
            FileInputStream fileinputstream=null;
			try {
				fileinputstream = new FileInputStream(file1);
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            
            for(; l1 < l2; l1 += i1)
            {
                try {
					i1 = fileinputstream.read(abyte0);
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
                try {
					fileoutputstream.write(abyte0, 0, i1);
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
            }

            try {
				fileinputstream.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        }
        try {
			fileoutputstream.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }

    public static void a(String s1)
    {
        b("NTLog", s1);
    }

    public static void a(String s1, String s2)
    {
        Object obj = v;
       
        h = "/data/data/%packetname%/files/".replaceFirst("%packetname%", s1);
        i = s2;
        File file = new File(h);
        if(!file.exists())
            file.mkdir();
        return;
    }

    static void a(String s1, String s2, int i1)
    {
        c(s1, s2, i1);
    }

    protected static void a(String s1, String s2, int i1, int j1)
    {
        if(s1 == null)
            s1 = "TAG_NULL";
        if(s2 == null)
            s2 = "MSG_NULL";
        if(j1 >= 2)
        {
            if((i1 & 1) != 0)
                b(s1, s2, j1);
            if((i1 & 0x10) != 0)
                d(s1, s2, j1);
            if((i1 & 0x1000) != 0 && l == null)
            {
                cls_b b1 = new cls_b();
                b1.getClass();
                l = new cls_a(b1);
                l.start();
            }
            if((i1 & 0x100) != 0)
                c(s1, s2, j1);
        }
    }

    public static File b(String s1)
    {
        File file;
        if(h == null || h.length() == 0)
            file = null;
        else
            file = new File((new StringBuilder()).append(h).append(s1).toString());
        return file;
    }

    public static void b(String s1, String s2)
    {
        a(s1, s2, 4368, 3);
    }

    private static void b(String s1, String s2, int i1)
    {
        switch(i1)
        {
      
        case 2:
        	Log.v(s1, s2);
        	break;
        case 3:
        	Log.d(s1, s2);
        	break;
        case 4:
        	Log.i(s1, s2);
        	break;
        case 5:
        	Log.w(s1, s2);
        	break;
        case 6:
        	Log.e(s1, s2);
        	break;
  default:
        	
        	break;
        }
        
    }

    public static String[] b()
    {
    	String as[];
        if(h == null || h.length() <= 0) {
        	as = null;
        } else
        {
        	Vector vector;
            vector = new Vector();
            File file = b("NTLog_log_last.txt");
            if(file.exists())
                vector.addElement(file.getAbsolutePath());
            File file1 = b("NTLog_log_now.txt");
            if(file1.exists())
                vector.addElement(file1.getAbsolutePath());
            if(vector.size() <= 0) {
            	 as = null;
            } else {
            	as = new String[vector.size()];
                vector.copyInto(as);
            }
        }
        return as;
        
    }

    public static void c()
    {
        Object obj = v;
        
        if(l == null)
        {
            cls_b b1 = new cls_b();
            b1.getClass();
            l = new cls_a(b1);
            l.start();
        }
        return;
    }

    public static void c(String s1, String s2)
    {
        a(s1, s2, 4368, 2);
    }

    private static void c(String s1, String s2, int i1)
    {
        Object obj = v;
       
        OutputStream outputstream = f();
        if(outputstream == null)
            return;
        byte abyte0[]=null;
		try {
			abyte0 = g(s1, s2).getBytes("utf-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        if(p >= 0x100000L){
        	try
            {
                g();
                h();
                c(s1, s2, i1);
            }
            catch(Exception exception1)
            {
                exception1.printStackTrace();
            }
              
        } else {
        	try {
				outputstream.write(abyte0);
			
            outputstream.write("\r\n".getBytes());
            outputstream.flush();
        	} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            p += abyte0.length;
        }

    }

    public static boolean c(String s1)
    {
        File file;
        e();
        file = b(s1);
        if(file.exists())
            file.delete();
        try {
			file.createNewFile();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
        boolean flag = com.nnee.p_pr.p_a.cls_e.a(b("NTLog_log_now.txt"), file);

        return flag;

    }

    public static void d()
    {
        if(l != null)
        {
            l.a();
            l = null;
        }
    }

    public static void d(String s1, String s2)
    {
        a(s1, s2, 4368, 6);
    }

    private static void d(String s1, String s2, int i1)
    {
    }

    public static void e()
    {
        Object obj = v;
        
        File file;
        g();
        file = b("NTLog_log_now.txt");
        if(file.exists())
            file.delete();
        try {
			file.createNewFile();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
        a(b("NTLog_log_last.txt"), b("NTLog_log.temp"), file, true);
        f();
 
        return;
      
    }

    public static void e(String s1, String s2)
    {
        a(s1, s2, 4368, 4);
    }

    private static OutputStream f()
    {
        OutputStream outputstream = null;
        if(o != null) {
        	 
        } else {
        	if(h != null && h.length() != 0) {
        		File file = b("NTLog_log.temp");
                if(file == null) {} else {
                    if(!file.exists()) {
                    	 try
                         {
                             o = new FileOutputStream(file);
                             p = 0L;
                         }
                         catch(FileNotFoundException filenotfoundexception)
                         {
                             filenotfoundexception.printStackTrace();
                         }
                         catch(IOException ioexception)
                         {
                             ioexception.printStackTrace();
                         }
                    	 
                    } else {
                    	try {
							o = new FileOutputStream(file, true);
						} catch (FileNotFoundException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
                        p = file.length();
                    }
                }
        	}
        }
        outputstream = o;
        return outputstream;
 
    }

    public static void f(String s1, String s2)
    {
        a(s1, s2, 4368, 5);
    }

    private static String g(String s1, String s2)
    {
        m.setTimeInMillis(System.currentTimeMillis());
        n.setLength(0);
        n.append("[");
        n.append(s1);
        n.append(" : ");
        n.append(1 + m.get(2));
        n.append("-");
        n.append(m.get(5));
        n.append(" ");
        n.append(m.get(11));
        n.append(":");
        n.append(m.get(12));
        n.append(":");
        n.append(m.get(13));
        n.append(":");
        n.append(m.get(14));
        n.append("] ");
        n.append(s2);
        return n.toString();
    }

    private static void g()
    {
        if(o != null)
        {
            try {
				o.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            o = null;
            p = 0L;
        }
 
        return;
         
    }

    private static void h()
    {
        Object obj = v;
        
        File file = b("NTLog_log.temp");
        File file1 = b("NTLog_log_last.txt");
        if(file1.exists())
            file1.delete();
        file.renameTo(file1);
        return;
    }

    public static final String a = "NTLog";
    public static boolean b = false;
    public static final int c = 1;
    public static final int d = 16;
    public static final int e = 256;
    public static final int f = 4096;
    public static final int g = 4368;
    static String h;
    static String i;
    public static final int j = 1;
    public static final int k = 2;
    public static cls_a l = null;
    static Calendar m = Calendar.getInstance();
    static StringBuffer n = new StringBuffer();
    static OutputStream o;
    static long p = 0L;
    private static final String q = "NTLog_log.temp";
    private static final String r = "NTLog_log_last.txt";
    private static final String s = "NTLog_log_now.txt";
    private static final int t = 2;
    private static final int u = 0x100000;
    private static Object v = new Object();
    private static final String w = "/data/data/%packetname%/files/";

    static 
    {
        b = true;
    }
}
